2017 vs 2020 Herring M2 from North Sea SMS

Output figures comparing M2 by predator (should match Morten’s outputs)

M2_2017 <- read_csv(here("KeyRunComparisons" , "NorthSeaSMS2017", "who_eats_whom_level1.csv"))
M2_2020 <- read_csv(here("KeyRunComparisons" , "NorthSeaSMS2020", "who_eats_whom_level1.csv"))

2017 Keyrun M2 (fixed y axis)

plist = lapply(split(M2_2017, M2_2017$Prey), function(d) {
  ggplot(d, aes(Year, Part.M2, fill=Predator)) + 
    geom_bar(stat = "identity") +
    facet_wrap(Prey~Prey.age) +
    xlab("Year") +
    ylab("M2") +
    theme_tufte() +
    theme(legend.position="bottom")
})

Cod

plist$Cod

Haddock

plist$Haddock

Herring

plist$Herring

N. Sandeel

plist$'N. sandeel'

S. Sandeel

plist$'S. sandeel'

Norway pout

plist$'Nor. pout'

Sprat

plist$Sprat

Whiting

plist$Whiting

2020 Keyrun M2 (fixed y axis)

plist2 = lapply(split(M2_2020, M2_2020$Prey), function(d) {
  ggplot(d, aes(Year, Part.M2, fill=Predator)) + 
    geom_bar(stat = "identity") +
    facet_wrap(Prey~Prey.age) +
    xlab("Year") +
    ylab("M2") +
    theme_tufte() +
    theme(legend.position="bottom")
})

Cod

plist2$Cod

Haddock

plist2$Haddock

Herring

plist2$Herring

N. Sandeel

plist2$'N. sandeel'

S. Sandeel

plist2$'S. sandeel'

Norway pout

plist2$'Nor. pout'

Sprat

plist2$Sprat

Whiting

plist2$Whiting

2017 Keyrun M2 (variable y axis)

plist3 = lapply(split(M2_2017, M2_2017$Prey), function(d) {
  ggplot(d, aes(Year, Part.M2, fill=Predator)) + 
    geom_bar(stat = "identity") +
    facet_wrap(Prey~Prey.age, scales = "free_y") +
    xlab("Year") +
    ylab("M2") +
    theme_tufte() +
    theme(legend.position="bottom")
})

Cod

plist3$Cod

Haddock

plist3$Haddock

Herring

plist3$Herring

N. Sandeel

plist3$'N. sandeel'

S. Sandeel

plist3$'S. sandeel'

Norway pout

plist3$'Nor. pout'

Sprat

plist3$Sprat

Whiting

plist3$Whiting

2020 Keyrun M2 (variable y axis)

plist4 = lapply(split(M2_2020, M2_2020$Prey), function(d) {
  ggplot(d, aes(Year, Part.M2, fill=Predator)) + 
    geom_bar(stat = "identity") +
    facet_wrap(Prey~Prey.age, scales = "free_y") +
    xlab("Year") +
    ylab("M2") +
    theme_tufte() +
    theme(legend.position="bottom")
})

Cod

plist4$Cod

Haddock

plist4$Haddock

Herring

plist4$Herring

N. Sandeel

plist4$'N. sandeel'

S. Sandeel

plist4$'S. sandeel'

Norway pout

plist4$'Nor. pout'

Sprat

plist4$Sprat

Whiting

plist4$Whiting

Compare Herring M2 between 2017 and 2020

Now tabs are herring predators

M2_2017 <- add_column(M2_2017, KeyRun = "SMS2017") 
M2_2020 <- add_column(M2_2020, KeyRun = "SMS2020")
M2_comp <- bind_rows(M2_2017, M2_2020)

M2_compHerring <- M2_comp %>%
  filter(Prey=="Herring") %>%
  group_by(Year, Predator, Prey, Prey.age, KeyRun) %>%
  summarise_at(vars(eatenW, Part.M2), funs(sum))

plist5 = lapply(split(M2_compHerring, M2_compHerring$Predator), function(d) {
  ggplot(d, aes(Year, Part.M2, group=KeyRun)) + 
    geom_point(aes(colour=KeyRun)) +
    facet_wrap(Prey~Prey.age, scales = "free_y", ncol = 2) +
    xlab("Year") +
    ylab("M2") +
    theme_tufte() +
    theme(legend.position="bottom")
})

Cod

plist5$Cod

Fulmar

plist5$Fulmar

G. gurnards

plist5$'G. gurnards'

Gannet

plist5$Gannet

GBB. Gull

plist5$'GBB. Gull'

Grey seal

plist5$'Grey seal'

Guillemot

plist5$Guillemot

H. porpoise

plist5$'H. porpoise'

Hake

plist5$Hake

Her. Gull

plist5$'Her. Gull'

Kittiwake

plist5$Kittiwake

Mackerel

plist5$Mackerel

N.horse mac

plist5$'N.horse mac'

Puffin

plist5$Puffin

Razorbill

plist5$Razorbill

Saithe

plist5$Saithe

Whiting

plist5$Whiting

Find biggest M2 differences for age 2 herring between key-runs:

M2_diffHerring <- M2_compHerring %>%
  arrange(Year, Predator, Prey, Prey.age, KeyRun) %>% 
  group_by(Year, Predator, Prey, Prey.age) %>% 
  mutate(diffM2_2020 = c(diff(Part.M2), NA),
         diffeatenW_2020 = c(diff(eatenW), NA)) %>%
  filter(!is.na(diffM2_2020))

age2diff <- M2_diffHerring %>%
  filter(Prey.age==2) %>%
  arrange(diffM2_2020)

library(DT)
datatable(age2diff, rownames = FALSE, options = list(pageLength = 25))